import React, {
    Component,
} from 'react';
import {
    StyleSheet,
    Text,
    View,
    Platform,
    Dimensions,
    TouchableOpacity,
    Image,
    Alert,
    FlatList,
    TextInput,
    Linking,
    DeviceEventEmitter,
    ScrollView
} from 'react-native';

import moment from 'moment';
import HttpUtils from '../../utils/HttpUtils';
import HttpUrls from '../../utils/HttpUrls';
import AndroidModule from "../../utils/AndroidConnent";
import { ToastToUser } from "../../utils/CustomToast";
import Constant from '../../utils/Constant'
import NoData from '../../utils/NoData'
import Loading from "../../utils/Loading";
import { getImgUrl, getCarRegisterDate, getMileFormat, getPriceFormat } from '../../utils/ComFunction'
import BankInfoPop from '../offerprice/orderComponents/BankInfoPop';
import LinearGradient from 'react-native-linear-gradient';
import { conditionObjWithType } from '../../utils/Conditions'
import { OrderStatus, AfterSaleStatus } from '../../utils/Enum'
import CancelOrderPop from './CancelOrderPop'
import CommonConfirmPop from '../../components/dialog/CommonConfirmPop';
import Picker from 'react-native-picker'
import BigImageContainer from '../../components/Tool/BigImageContainer';
import Clipboard from '@react-native-clipboard/clipboard';

let navigation
/**
 * 售后订单详情
 */
export default class AfterSaleOrderDetail extends Component {
    constructor(props) {
        super(props);

        this.state = {
            title: '售后订单详情',
            orderNo: this.props.route.params.orderNo,
            carInfo: {},
            isShowBankInfo: false,
            orderStatus: '',
            orderInfo: {},
            receivePaymentBank: '',
            receivePaymentBankAccount: '',
            receivePaymentAccountName: '',
            isShowCacelPop: false,
            logisticsInfo: {},
            afterSalesType: '',//售后类型 1改价 2退车退款
            afterSalesStatus: '',//售后订单状态

            checkStatus: '',//检测状态

            contractSignTimeOut: null,
            shipmentTimeOut: '',
            receiptTimeOut: '',//收货倒计时
            logisticsTimeOut: '',//车辆运输中倒计时
            advanceConfirmTimeOut: 0,
            advancePayTimeOut: 0,
            tailConfirmTimeOut: 0,
            tailPayTimeOut: 0,
            isRefund: true,
            isShowPlatformIntervene: false,
            applyConfirmTimeOut: '',//售后待确认倒计时
            paymentTimeOut: '',//卖家打款倒计时
            confirmReceiptVisible: false,
            showPicList: [],
            showPics: false,
            showPicIndex: 0
        }
    }

    componentDidMount() {
        if (this.Loading) {
            this.Loading.show()
        }
        this.getOrderDetail()



        this.refreshOrderDetail = DeviceEventEmitter.addListener('refreshAfterOrderDetail', (data) => {
            this.getOrderDetail()
        })
        this.paySuccessListener = DeviceEventEmitter.addListener('paySuccess', (data) => {
            this.getOrderDetail()
        })
    }

    componentWillUnmount() {
        if (this.refreshOrderDetail) {
            this.refreshOrderDetail.remove()
        }
        if (this.paySuccessListener) {
            this.paySuccessListener.remove()
        }

    }

    render() {
        navigation = this.props.navigation;
        return (
            <View style={styles.container}>
                <Header navigation={navigation} Title={this.state.title} hideSepLine={true} bgColor={'#f9f9f9'}></Header>

                <ScrollView
                    style={styles.scrollContain}
                    showsVerticalScrollIndicator={false}
                >
                    {this.renderOrderStatus()}
                    {this.renderTypeInfo()}

                    {this.renderOrderInfo()}

                    {this.renderCarInfo()}


                </ScrollView>

                {this.renderBottom()}

                {this.state.confirmReceiptVisible ?
                    <CommonConfirmPop
                        visible={this.state.confirmReceiptVisible}
                        content={'确认收货后'}
                        redText={'系统将支付退款到买家账户，请确认'}
                        content2={''}
                        onClose={() => {
                            this.setState({
                                confirmReceiptVisible: false
                            })


                        }}
                        onCancel={() => {
                            this.setState({
                                confirmReceiptVisible: false
                            })

                        }}
                        onSure={() => {
                            this.setState({
                                dialogVisible: false
                            })
                            this.afterSaleConfirmReceipt()

                        }}
                        sureText={'确认'}
                        cancelText={'返回'}

                    >

                    </CommonConfirmPop>
                    :
                    null
                }

                {
                    this.state.showPics ?
                        <BigImageContainer
                            idx={this.state.showPicIndex}
                            images={this.state.showPicList}
                            closeHandler={(index) => {
                                this.setState({

                                    showPics: false
                                })
                            }}
                        />
                        :
                        null
                }

                <Loading onRef={(ref) => (this.Loading = ref)} />

            </View>
        )
    }

    renderOrderStatus() {
        return (
            <View style={styles.orderStatusContain}>
                <Text style={styles.orderStatusText}>{this.getOrderStatusTitleText()}</Text>
                {this.getOrderStatusText()}

            </View>
        )
    }

    getOrderStatusTitleText() {



        if (this.state.orderStatus == AfterSaleStatus.OrderStatusWaitConfirm) {
            if (Constant.userInfo.isFranchisee == '1') {
                return '请受理售后申请'
            } else {
                return '待对方确认'
            }
        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusWaitSign) {
            if (Constant.userInfo.isFranchisee == '1') {//
                return '请签署合同'
            } else {//
                return '待签署合同'
            }
        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusSigning) {
            if (Constant.userInfo.isFranchisee == '1') {//卖家
                if (this.isBuyerNotContractSign() && this.isSellerNotContractSign()) {//均未签署
                    return '请签署合同'
                } else if (this.state.orderInfo.buyerContractSign == '1' && this.isSellerNotContractSign()) {//买家已签署，卖家未签署
                    return '待我方签署合同'
                } else if (this.isBuyerNotContractSign() && this.state.orderInfo.sellerContractSign == '1') {//卖家已签署，买家未签署
                    return '待对方签署合同'
                } else {
                    return '合同已签署'
                }
            } else {
                if (this.isBuyerNotContractSign() && this.isSellerNotContractSign()) {//均未签署
                    return '请签署合同'
                } else if (this.state.orderInfo.buyerContractSign == '1' && this.isSellerNotContractSign()) {//买家已签署，卖家未签署
                    return '待对方签署合同'
                } else if (this.isBuyerNotContractSign() && this.state.orderInfo.sellerContractSign == '1') {//卖家已签署，买家未签署
                    return '待我方签署合同'
                } else {
                    return '合同已签署'
                }
            }
        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusWaitDelivery) {

            if (Constant.userInfo.isFranchisee == '1') {//卖家
                if (this.state.logisticsInfo.deliveryConfirm == '1') {//收货方已确认
                    if (this.state.logisticsInfo.shippingConfirm == '1') {

                        if (this.state.logisticsInfo.transportStatus == '2') {
                            return '司机已提车，待发货'
                        }
                        return '物流已下单，待司机提车'
                    }
                    return '待确认退货物流信息'
                } else {
                    return '请确认退货物流信息'

                }
            } else {
                if (this.state.logisticsInfo.shippingConfirm == '1') {//已确认
                    if (this.state.logisticsInfo.deliveryConfirm == '1') {
                        if (this.state.logisticsInfo.transportStatus == '2') {
                            return '司机已提车，待发货'
                        }
                        return '物流已下单，待司机提车'
                    }
                    return '待确认退货物流信息'
                } else {

                    return '请确认退货物流信息'
                }

            }
        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusWaitSettlement) {

            if (Constant.userInfo.isFranchisee == '1') {//卖家
                return '请支付退款'
            } else {
                return '待卖家支付退款'
            }


        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusWaitReceipt) {
            if (Constant.userInfo.isFranchisee == '1') {
                if (this.state.logisticsInfo.transportStatus == '6') {//已交车
                    return '物流已交车，请签收'
                }
                return '车辆运输中'
            } else {
                if (this.state.logisticsInfo.transportStatus == '6') {//已交车
                    return '物流已交车，待签收'
                }
                return '车辆运输中'
            }
        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusFinisded) {

            if (this.state.afterSalesType == '1') {//改价

                if (this.state.isRefund) {//有退款
                    return '已完成退款'
                } else {
                    return '售后已完成'
                }

            } else if (this.state.afterSalesType == '2') {//退车
                return '已完成退款'
            }


        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusClosed) {
            return '售后已关闭'
        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusCancel) {
            return '售后已取消'
        }


    }

    isBuyerNotContractSign() {
        return !this.state.orderInfo.buyerContractSign || this.state.orderInfo.buyerContractSign == '0'
    }

    isSellerNotContractSign() {
        return !this.state.orderInfo.sellerContractSign || this.state.orderInfo.sellerContractSign == '0'
    }

    getOrderStatusText() {

        if (this.state.orderStatus == AfterSaleStatus.OrderStatusWaitConfirm) {
            if (Constant.userInfo.isFranchisee == '1') {
                return (
                    <Text style={styles.orderStatusText2}><Text style={styles.timeColorText}>{this.formatTime(this.state.applyConfirmTimeOut)}</Text>后平台将介入</Text>
                )
            } else {
                return (
                    <Text style={styles.orderStatusText2}><Text style={styles.timeColorText}>{this.formatTime(this.state.applyConfirmTimeOut)}</Text>后平台将介入</Text>
                )
            }
        }
        else if (this.state.orderStatus == AfterSaleStatus.OrderStatusWaitSign || this.state.orderStatus == AfterSaleStatus.OrderStatusSigning) {
            if (this.state.contractSignTimeOut === 0) {
                return (
                    <Text style={styles.orderStatusText2}>已超时</Text>
                )
            }
            if (Constant.userInfo.isFranchisee == '1') {
                if ((this.isBuyerNotContractSign() && this.isSellerNotContractSign())
                    || (this.state.orderInfo.buyerContractSign == '1' && this.isSellerNotContractSign())) {//均未签署  买家已签署，卖家未签署

                    return (
                        <Text style={styles.orderStatusText2}>原合同作废，请重签，<Text style={styles.timeColorText}>{this.formatTime(this.state.contractSignTimeOut)}</Text>后平台将介入</Text>
                    )
                } else if (this.isBuyerNotContractSign() && this.state.orderInfo.sellerContractSign == '1') {//卖家已签署，买家未签署
                    return null
                } else {
                    return null
                }
            } else {
                if ((this.isBuyerNotContractSign() && this.isSellerNotContractSign())
                    || (this.isBuyerNotContractSign() && this.state.orderInfo.sellerContractSign == '1')) {//均未签署

                    return (
                        <Text style={styles.orderStatusText2}>原合同作废，待重签，<Text style={styles.timeColorText}>{this.formatTime(this.state.contractSignTimeOut)}</Text>后平台将介入</Text>
                    )
                } else if (this.state.orderInfo.buyerContractSign == '1' && this.isSellerNotContractSign()) {//买家已签署，卖家未签署
                    return null
                } else {
                    return null
                }
            }

        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusWaitDelivery) {

            // if (this.state.logisticsInfo.transportStatus == '1' || this.state.logisticsInfo.transportStatus == '2') {//待提车或已提车
            //     return null
            // }

            if (this.state.shipmentTimeOut === 0) {//超时
                return (
                    <Text style={styles.orderStatusText2}>已超时</Text>
                )
            }

            if (Constant.userInfo.isFranchisee == '1') {//卖家

                //待发货状态 请确认退车信息，xxx后平台将介入 已发货等待司机提车和司机已提车不显示

                if (this.state.logisticsInfo.deliveryConfirm == '1') {//已确认
                    return (
                        <Text style={styles.orderStatusText2}><Text style={styles.timeColorText}>{this.formatTime(this.state.shipmentTimeOut)}</Text>后平台将介入</Text>
                    )
                } else {
                    return (
                        <Text style={styles.orderStatusText2}>请确认退车信息，<Text style={styles.timeColorText}>{this.formatTime(this.state.shipmentTimeOut)}</Text>后将平台介入</Text>
                    )
                }



            } else {
                if (this.state.logisticsInfo.shippingConfirm == '1') {//已确认
                    return (
                        <Text style={styles.orderStatusText2}><Text style={styles.timeColorText}>{this.formatTime(this.state.shipmentTimeOut)}</Text>后平台将介入</Text>
                    )
                } else {
                    return (
                        <Text style={styles.orderStatusText2}>请确认退车信息，<Text style={styles.timeColorText}>{this.formatTime(this.state.shipmentTimeOut)}</Text>后将平台介入</Text>
                    )
                }

            }

        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusWaitSettlement) {

            if (this.state.paymentTimeOut === 0) {//超时
                return (
                    <Text style={styles.orderStatusText2}>已超时</Text>
                )
            }

            if (Constant.userInfo.isFranchisee == '1') {//卖家
                return (
                    <Text style={styles.orderStatusText2}><Text style={styles.timeColorText}>{this.formatTime(this.state.paymentTimeOut)}</Text>后未支付平台将介入</Text>
                )
            } else {
                return (
                    <Text style={styles.orderStatusText2}><Text style={styles.timeColorText}>{this.formatTime(this.state.paymentTimeOut)}</Text>后卖家未支付平台将介入</Text>
                )
            }
        }
        else if (this.state.orderStatus == AfterSaleStatus.OrderStatusWaitReceipt) {

            if (Constant.userInfo.isFranchisee == '1') {
                if (this.state.logisticsInfo.transportStatus == '6') {//已交车
                    if (this.state.receiptTimeOut === 0) {//超时
                        return (
                            <Text style={styles.orderStatusText2}>已超时</Text>
                        )
                    }
                    return (
                        <Text style={styles.orderStatusText2}><Text style={styles.timeColorText}>{this.formatTime(this.state.receiptTimeOut)}</Text>后未确认收货，平台将介入</Text>
                    )
                }
                return (
                    <Text style={styles.orderStatusText2}><Text style={styles.timeColorText}>{this.formatTime(this.state.logisticsTimeOut)}</Text>后未交车平台将介入</Text>
                )
            } else {
                if (this.state.logisticsInfo.transportStatus == '6') {//已交车
                    if (this.state.receiptTimeOut === 0) {//超时
                        return (
                            <Text style={styles.orderStatusText2}>已超时</Text>
                        )
                    }
                    return (
                        <Text style={styles.orderStatusText2}><Text style={styles.timeColorText}>{this.formatTime(this.state.receiptTimeOut)}</Text>后未确认收货，平台将介入</Text>
                    )
                }
                return (
                    <Text style={styles.orderStatusText2}><Text style={styles.timeColorText}>{this.formatTime(this.state.logisticsTimeOut)}</Text>后未交车平台将介入</Text>
                )
            }



        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusFinisded) {

        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusClosed) {

        }
    }

    formatTime(seconds) {
        if (seconds == null || seconds == undefined) {
            return '';
        }
        const h = Math.floor(seconds / 3600);
        const m = Math.floor((seconds % 3600) / 60);
        const s = seconds % 60;

        // const formattedH = h.toString().padStart(2, '0');
        // const formattedM = m.toString().padStart(2, '0');
        // const formattedS = s.toString().padStart(2, '0');

        if (h == 0) {
            return ` ${m}分${s}秒`;
        }
        return ` ${h}小时${m}分${s}秒`;
    }

    renderTypeInfo() {
        return (
            <View style={styles.orderInfoContain}>
                <Text style={styles.titleText}>售后方案</Text>
                <View style={styles.infoBox}>
                    <Text style={styles.itemTitleText}>售后类型</Text>
                    <Text style={styles.itemPriceText}>{this.state.afterSalesType == '1' ? '修改采购价' : '退车退款'}</Text>
                </View>
                {this.state.afterSalesType == '1' ?

                    <View style={styles.infoBox}>
                        <Text style={styles.itemTitleText}>修改成交价</Text>

                        <View style={{ flexDirection: 'row', alignItems: 'center' }}>
                            <Text style={styles.itemPriceText}>{this.state.orderInfo.orderPurchasePrice / (100)}元</Text>
                            <Image source={require('source/image/comm/icon_right_arrow.png')} style={styles.arrowRightImage}></Image>
                            <Text style={styles.itemPriceText}>{this.state.orderInfo.finalPurchasePrice / (100)}元</Text>
                        </View>

                    </View>
                    :
                    null
                }


                {this.state.afterSalesType == '1' ?
                    <View style={styles.infoBox}>
                        <Text style={styles.itemTitleText}>订单终价</Text>
                        <Text style={styles.itemPriceText}>¥{this.state.orderInfo.finalTradePrice / (100)}元</Text>
                    </View>
                    : null
                }


                {this.state.afterSalesType == '1' ?
                    <View style={styles.moneyInfoBox}>
                        <View style={styles.infoBox2}>
                            <Text style={styles.itemTitleText}>车辆成交价</Text>
                            <Text style={styles.itemPriceText}>¥{this.state.orderInfo.finalPurchasePrice / (100)}元{ }</Text>
                        </View>
                        <View style={styles.infoBox2}>
                            <Text style={styles.itemTitleText}>已预付</Text>
                            <Text style={styles.itemPriceText}>-¥{this.state.orderInfo.advancePayment / (100)}元</Text>
                        </View>
                        <View style={styles.infoBox2}>
                            <Text style={styles.itemTitleText}>门店服务费</Text>
                            <Text style={styles.itemPriceText}>¥{this.state.orderInfo.detectionFee / (100)}元</Text>
                        </View>
                        {this.state.isRefund ? null :
                            <View style={styles.infoBox2}>
                                <Text style={styles.itemTitleText}>尾款</Text>
                                <Text style={styles.itemPriceText}>¥{this.state.orderInfo.tailPayment / (100)}元</Text>
                            </View>

                        }

                    </View>
                    : null
                }

                <View style={styles.infoBox}>
                    <Text style={styles.itemTitleText}>订单应退总额</Text>
                    <Text style={styles.itemPriceText}>¥{this.state.orderInfo.totalRefundAmount / (100)}元</Text>
                </View>

                {this.state.isRefund ?
                    <View style={styles.infoBox}>
                        <Text style={styles.itemTitleText}>卖家应退总额</Text>
                        <Text style={[styles.itemPriceText, { color: 'red' }]}>¥{this.state.orderInfo.refundAmount / (100)}元</Text>
                    </View>
                    : null
                }


                {this.state.afterSalesType == '2' ?
                    <View style={styles.infoBox}>
                        <Text style={styles.itemTitleText}>退车方式</Text>
                        <Text style={styles.itemPriceText}>上门提车</Text>
                    </View>
                    : null
                }

                {/* {this.state.isRefund && this.state.afterSalesType == '1' && Constant.userInfo.isFranchisee == 1 ?
                    <View>
                        <Text style={[styles.itemTitleText, { marginTop: 10, marginBottom: 10 }]}>请付款至该账户</Text>
                        <View style={styles.moneyInfoBox}>
                            <View style={styles.infoBox2}>
                                <Text style={styles.itemTitleText}>收款银行</Text>
                                <Text style={styles.itemPriceText}>{this.state.orderInfo.receiveBankName}</Text>
                            </View>
                            <View style={styles.infoBox2}>
                                <Text style={styles.itemTitleText}>收款账号</Text>
                                <Text style={styles.itemPriceText}>{this.state.orderInfo.receiveBankAccount}</Text>
                            </View>
                            <View style={styles.infoBox2}>
                                <Text style={styles.itemTitleText}>账户名称</Text>
                                <Text style={styles.itemPriceText}>{this.state.orderInfo.receiveAccountName}</Text>
                            </View>
                        </View>
                    </View>
                    :
                    null
                } */}

            </View>
        )
    }

    renderAddressInfo() {
        return (
            <View style={styles.addressInfoBox}
            >
                <Image style={styles.locationImg} source={require('source/image/location_icon.png')} />
                <View style={{ flex: 1, flexDirection: 'column', alignItems: 'flex-start', justifyContent: 'center', marginLeft: 12 }}>
                    <Text style={styles.addressText} numberOfLines={1} ellipsizeMode={'tail'}>{this.state.orderInfo.buyerAddressStr}</Text>
                    <Text style={styles.nameText}>{this.state.orderInfo.buyerConsigneeName + ' ' + this.state.orderInfo.buyerConsigneePhone}</Text>
                </View>

            </View>
        )
    }

    renderCarInfo() {
        return (
            <View style={styles.orderInfoContain}>

                <TouchableOpacity style={{ flexDirection: 'row', alignItems: 'center' }}
                    onPress={() => { navigation.navigate('CarDetailPage', { carId: this.state.orderInfo.carId, merchantId: this.state.orderInfo.sellerMerchantId }) }}>
                    <Image style={styles.carImg} source={{ uri: getImgUrl(this.state.orderInfo.mainPic) }} />
                    <View style={styles.carInfoBox}>
                        <Text style={styles.brandText}>{this.state.orderInfo.carName ? this.state.orderInfo.carName.replaceAll('#', ' ') : ''}</Text>
                        <Text style={styles.carInfoText}>{this.getSubCarInfo(this.state.orderInfo)}</Text>
                        {/* <Text style={styles.carPriceText}>{'成交价 ' + (this.state.orderInfo.quotationAmount / (100 * 10000))}万元</Text> */}
                    </View>
                </TouchableOpacity>



            </View>
        )
    }

    getSubCarInfo(item) {


        let carInfoStr = ''
        if (item.registerDate && item.registerDate != null) {


            carInfoStr = moment(item.registerDate).format('YYYY-MM')
        }

        if (item.mileage && item.mileage != 0) {
            carInfoStr = carInfoStr + ' | ' + getMileFormat(item.mileage)
        }

        if (item.sellerUserCityName && item.sellerUserCityName != '') {
            if (carInfoStr != '') {
                carInfoStr = carInfoStr + ' | ' + item.sellerUserCityName
            } else {
                carInfoStr = item.sellerUserCityName
            }

        }

        return carInfoStr
    }

    copyText(copyText) {
        Clipboard.setString(copyText);
        ToastToUser('复制成功');
    }


    renderOrderInfo() {
        return (
            <View style={styles.orderInfoContain}>
                <Text style={styles.titleText}>服务单信息</Text>
                <View style={styles.infoBox}>
                    <Text style={styles.itemTitleText}>订单编号</Text>
                    <View style={{ flexDirection: 'row', alignItems: 'center' }}>
                        <Text style={styles.itemTitleText}>{this.state.orderInfo.quotationOrderNo}</Text>

                        <TouchableOpacity
                            style={{ width: 30, height: 30, justifyContent: 'center', alignItems: 'center' }}
                            onPress={() => { this.copyText(this.state.orderInfo.quotationOrderNo) }}>
                            <Image style={styles.copyImg} source={require('source/image/comm/icon_copy.png')} />
                        </TouchableOpacity>
                    </View>

                </View>
                <View style={styles.infoBox}>
                    <Text style={styles.itemTitleText}>服务单编号</Text>
                    <View style={{ flexDirection: 'row', alignItems: 'center' }}>
                    <Text style={styles.itemTitleText}>{this.state.orderInfo.afterSalesNo}</Text>

                        <TouchableOpacity
                            style={{ width: 30, height: 30, justifyContent: 'center', alignItems: 'center' }}
                            onPress={() => { this.copyText(this.state.orderInfo.afterSalesNo) }}>
                            <Image style={styles.copyImg} source={require('source/image/comm/icon_copy.png')} />
                        </TouchableOpacity>
                    </View>
                    
                </View>



                <View style={styles.infoBox}>
                    <Text style={styles.itemTitleText}>申请时间</Text>
                    <Text style={styles.itemTitleText}>{this.state.orderInfo.createTime}</Text>
                </View>
                <View style={styles.infoBox}>
                    <Text style={styles.itemTitleText}>申请理由</Text>
                    <Text style={styles.itemTitleText}>{conditionObjWithType('afterSaleReason')[this.state.orderInfo.afterSalesReason]}</Text>
                </View>

                <View style={styles.infoBoxNoHeight}>
                    <Text style={styles.itemTitleText}>问题描述</Text>
                    <Text style={[styles.itemTitleText, { flex: 1, marginLeft: 10, textAlign: 'right' }]}>{this.state.orderInfo.afterSalesRemark}</Text>
                </View>

                {this.state.orderInfo.refuseReason ?
                    <View style={styles.infoBoxNoHeight}>
                        <Text style={styles.itemTitleText}>拒绝理由</Text>
                        <Text style={[styles.itemTitleText, { flex: 1, marginLeft: 10, textAlign: 'right' }]}>{this.state.orderInfo.refuseReason == 1 ? '方案不认同' : this.state.orderInfo.refuseReason == 2 ? '金额不认同' : '检测车况一致'}</Text>
                    </View>
                    :
                    null
                }


                {this.state.orderInfo.carAbnormalPics && this.state.orderInfo.carAbnormalPics != '' ?
                    <View>
                        <Text style={styles.itemTitleText}>问题照片</Text>
                        <View style={{ flexDirection: 'row', flexWrap: 'wrap' }}>
                            {this.state.orderInfo.carAbnormalPics.split(',').map((item, index) => {
                                return (
                                    <TouchableOpacity
                                        onPress={() => {
                                            this.setState({
                                                showPicIndex: index,
                                                showPics: true
                                            })
                                        }}>
                                        <Image key={index} source={{ uri: getImgUrl(item) }} style={{ width: 100, height: 100, borderRadius: 4, marginRight: 10, marginTop: 10 }} />
                                    </TouchableOpacity>

                                )
                            })}
                        </View>
                    </View>
                    :
                    null
                }



            </View>
        )
    }

    renderBottom() {
        return (
            <View style={[styles.bottomContain, { paddingBottom: Constant.bottomHeight }]}>

                {Constant.userInfo.isFranchisee == '1' && this.state.orderStatus == AfterSaleStatus.OrderStatusWaitSign
                    ?
                    <View style={styles.contractFeeContain}>
                        <Text style={styles.itemPriceTitle}>合同费用<Text style={{ color: '#999999' }}>（余额扣款）</Text></Text>
                        <Text style={[styles.itemPriceValue, { color: '#ED542E' }]}>¥{this.state.orderInfo.contractFee / 100}</Text>
                    </View>
                    :
                    null
                }


                <View style={styles.bottomContain2}>
                    <View>
                        <View style={{ flexDirection: 'row', alignItems: 'center', justifyContent: 'center', marginRight: 8 }}>
                            <TouchableOpacity
                                style={styles.bottomitemBox}
                                activeOpacity={0.8}
                                onPress={() => {
                                    this.consultOnline()
                                }}
                            >
                                <Image style={styles.bottomitemImg} source={require('source/image/chat_online_icon.png')} />
                                <Text style={styles.bottomitemText}>在线咨询</Text>
                            </TouchableOpacity>




                        </View>
                    </View>

                    <View style={{ flexDirection: 'row', alignItems: 'center' }}>

                        {this.state.orderInfo.contractNo && this.state.orderInfo.contractNo != '' && this.state.orderStatus !== AfterSaleStatus.OrderStatusSigning ?
                            <TouchableOpacity
                                activeOpacity={0.8}
                                style={[styles.bottomBtnCancel, { width: 100 }]}
                                onPress={() => {
                                    navigation.navigate('ContractDetailPage', { contractNo: this.state.orderInfo.contractNo, orderNo: this.state.orderNo });
                                }}
                            >
                                <Text style={styles.bottomRightItemText}>查看合同</Text>
                            </TouchableOpacity>
                            : null
                        }


                        {this.getRightBottomBtn()}
                    </View>
                </View>
            </View>
        )
    }

    /**
     * 
     * 
     */
    getRightBottomBtn() {

        if (this.state.orderStatus === AfterSaleStatus.OrderStatusWaitConfirm) {
            if ((Constant.userInfo.isFranchisee == '1')) {

                return (
                    <View style={{ flexDirection: 'row' }}>
                        <TouchableOpacity
                            activeOpacity={0.8}
                            style={[styles.bottomBtnCancel, { width: 100 }]}
                            onPress={() => {
                                this.showTypePicker()

                            }}
                        >
                            <Text style={styles.bottomRightItemText}>拒绝申请</Text>
                        </TouchableOpacity>

                        <TouchableOpacity
                            activeOpacity={0.8}
                            style={[styles.bottomBtn1, { width: 100 }]}
                            onPress={() => {
                                this.confirmAfterSaleOrder()
                            }}
                        >
                            <LinearGradient start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}
                                colors={['#FFEF3A', '#FFDB1B']}
                                style={styles.itemInnerBox}>
                                <Text style={styles.bottomRightItemText}>确认售后</Text>

                            </LinearGradient>
                        </TouchableOpacity>
                    </View>
                )
            } else {
                return (
                    <View style={{ flexDirection: 'row' }}>
                        {this.state.isShowPlatformIntervene ?
                            <TouchableOpacity
                                activeOpacity={0.8}
                                style={[styles.bottomBtn1, { marginRight: 10 }]}
                                onPress={() => {
                                    this.applyPlatformProcessing()

                                }}
                            >
                                <LinearGradient start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}
                                    colors={['#FFEF3A', '#FFDB1B']}
                                    style={styles.itemInnerBox}>
                                    <Text style={styles.bottomRightItemText}>平台介入</Text>

                                </LinearGradient>
                            </TouchableOpacity>
                            : null
                        }



                        <TouchableOpacity
                            activeOpacity={0.8}
                            style={styles.bottomBtn1}
                            onPress={() => {
                                this.cancelOrder()

                            }}
                        >
                            <LinearGradient start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}
                                colors={['#FFEF3A', '#FFDB1B']}
                                style={styles.itemInnerBox}>
                                <Text style={styles.bottomRightItemText}>撤销售后</Text>

                            </LinearGradient>
                        </TouchableOpacity>

                    </View>

                )

            }
        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusWaitSign) {
            if (Constant.userInfo.isFranchisee == '1') {
                return (
                    <TouchableOpacity
                        activeOpacity={0.8}
                        style={styles.bottomBtn1}
                        onPress={() => {
                            navigation.navigate('SignMainBodyPage', { orderNo: this.state.orderNo, from: 'afterSales', afterSalesType: this.state.afterSalesType })


                        }}
                    >
                        <LinearGradient start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}
                            colors={['#FFEF3A', '#FFDB1B']}
                            style={styles.itemInnerBox}>
                            <Text style={styles.bottomRightItemText}>发起合同</Text>

                        </LinearGradient>
                    </TouchableOpacity>
                )
            }
        }

        else if (this.state.orderStatus == AfterSaleStatus.OrderStatusSigning || this.state.orderStatus == AfterSaleStatus.OrderStatusRejectSign) {
            if (Constant.userInfo.isFranchisee == '1') {//卖家
                if (this.state.orderInfo.sellerContractSign == '1') {//卖家已签署

                } else {
                    return (
                        <TouchableOpacity
                            activeOpacity={0.8}
                            style={styles.bottomBtn1}
                            onPress={() => {
                                navigation.navigate('ContractDetailPage', { contractNo: this.state.orderInfo.contractNo, orderNo: this.state.orderNo })

                            }}
                        >
                            <LinearGradient start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}
                                colors={['#FFEF3A', '#FFDB1B']}
                                style={styles.itemInnerBox}>
                                <Text style={styles.bottomRightItemText}>签署合同</Text>

                            </LinearGradient>
                        </TouchableOpacity>
                    )
                }
            } else {
                if (this.state.orderInfo.buyerContractSign == '1') {//买家已签署

                } else {
                    return (
                        <TouchableOpacity
                            activeOpacity={0.8}
                            style={styles.bottomBtn1}
                            onPress={() => {
                                navigation.navigate('ContractDetailPage', { contractNo: this.state.orderInfo.contractNo, orderNo: this.state.orderNo })

                            }}
                        >
                            <LinearGradient start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}
                                colors={['#FFEF3A', '#FFDB1B']}
                                style={styles.itemInnerBox}>
                                <Text style={styles.bottomRightItemText}>签署合同</Text>

                            </LinearGradient>
                        </TouchableOpacity>
                    )
                }
            }
        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusWaitSettlement) {//待结算
            if (Constant.userInfo.isFranchisee == '1') {//卖家
                return (
                    <TouchableOpacity
                        activeOpacity={0.8}
                        style={styles.bottomBtn1}
                        onPress={() => {
                            this.confirmPay(this.state.orderInfo.refundAmount)

                        }}
                    >
                        <LinearGradient start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}
                            colors={['#FFEF3A', '#FFDB1B']}
                            style={styles.itemInnerBox}>
                            <Text style={styles.bottomRightItemText}>立即付款</Text>

                        </LinearGradient>
                    </TouchableOpacity>
                )

            } else {

            }
        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusWaitDelivery) {//待发货
            if (Constant.userInfo.isFranchisee == '1') {//卖家
                if (!this.state.logisticsInfo.deliveryConfirm || this.state.logisticsInfo.deliveryConfirm == '0') {//
                    return (
                        <TouchableOpacity
                            activeOpacity={0.8}
                            style={styles.bottomBtn1}
                            onPress={() => {
                                navigation.navigate('LogisticsOrderingSubmitPage', {
                                    orderNo: this.state.orderNo, from: 'afterSale', submitHandler: () => {
                                        this.getOrderDetail()
                                    }
                                })
                            }}
                        >
                            <LinearGradient start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}
                                colors={['#FFEF3A', '#FFDB1B']}
                                style={styles.itemInnerBox}>
                                <Text style={styles.bottomRightItemText}>物流确认</Text>

                            </LinearGradient>
                        </TouchableOpacity>
                    )
                } else {
                    if (this.state.orderInfo.logisticsNo && this.state.orderInfo.logisticsNo != '') {
                        return (
                            <TouchableOpacity
                                activeOpacity={0.8}
                                style={styles.bottomBtn1}
                                onPress={() => {
                                    navigation.navigate('LogisticsTrackPage', { logisticsNo: this.state.orderInfo.logisticsNo });
                                }}
                            >
                                <LinearGradient start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}
                                    colors={['#FFEF3A', '#FFDB1B']}
                                    style={styles.itemInnerBox}>
                                    <Text style={styles.bottomRightItemText}>查看物流</Text>

                                </LinearGradient>
                            </TouchableOpacity>
                        )
                    }
                }
            } else {
                if (!this.state.logisticsInfo.shippingConfirm || this.state.logisticsInfo.shippingConfirm == '0') {//
                    return (
                        <TouchableOpacity
                            activeOpacity={0.8}
                            style={styles.bottomBtn1}
                            onPress={() => {
                                navigation.navigate('LogisticsOrderingSubmitPage', {
                                    orderNo: this.state.orderNo, from: 'afterSale', submitHandler: () => {
                                        this.getOrderDetail()
                                    }
                                })
                            }}
                        >
                            <LinearGradient start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}
                                colors={['#FFEF3A', '#FFDB1B']}
                                style={styles.itemInnerBox}>
                                <Text style={styles.bottomRightItemText}>物流确认</Text>

                            </LinearGradient>
                        </TouchableOpacity>
                    )
                } else {
                    //如果有物流单
                    if (this.state.orderInfo.logisticsNo && this.state.orderInfo.logisticsNo != '') {
                        return (
                            <TouchableOpacity
                                activeOpacity={0.8}
                                style={styles.bottomBtn1}
                                onPress={() => {
                                    navigation.navigate('LogisticsTrackPage', { logisticsNo: this.state.orderInfo.logisticsNo });
                                }}
                            >
                                <LinearGradient start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}
                                    colors={['#FFEF3A', '#FFDB1B']}
                                    style={styles.itemInnerBox}>
                                    <Text style={styles.bottomRightItemText}>查看物流</Text>

                                </LinearGradient>
                            </TouchableOpacity>
                        )
                    }

                }

            }
        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusWaitReceipt) {//待收货
            if (Constant.userInfo.isFranchisee == '1') {//卖家
                return (
                    <View style={{ flexDirection: 'row' }}>
                        <TouchableOpacity
                            activeOpacity={0.8}
                            style={[styles.bottomBtn1, { width: 85, marginRight: 10 }]}
                            onPress={() => {
                                navigation.navigate('LogisticsTrackPage', { logisticsNo: this.state.orderInfo.logisticsNo });
                            }}
                        >
                            <LinearGradient start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}
                                colors={['#FFEF3A', '#FFDB1B']}
                                style={styles.itemInnerBox}>
                                <Text style={styles.bottomRightItemText}>查看物流</Text>

                            </LinearGradient>

                        </TouchableOpacity>
                        {this.state.logisticsInfo.transportStatus == '6' ?
                            <TouchableOpacity
                                activeOpacity={0.8}
                                style={[styles.bottomBtn1, { width: 85 }]}
                                onPress={() => {
                                    this.setState({
                                        confirmReceiptVisible: true
                                    })

                                }}
                            >
                                <LinearGradient start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}
                                    colors={['#FFEF3A', '#FFDB1B']}
                                    style={styles.itemInnerBox}>
                                    <Text style={styles.bottomRightItemText}>确认收货</Text>

                                </LinearGradient>
                            </TouchableOpacity>
                            : null
                        }


                    </View>

                )
            } else {
                return (
                    <TouchableOpacity
                        activeOpacity={0.8}
                        style={styles.bottomBtn1}
                        onPress={() => {
                            navigation.navigate('LogisticsTrackPage', { logisticsNo: this.state.orderInfo.logisticsNo });
                        }}
                    >
                        <LinearGradient start={{ x: 0, y: 0 }} end={{ x: 1, y: 0 }}
                            colors={['#FFEF3A', '#FFDB1B']}
                            style={styles.itemInnerBox}>
                            <Text style={styles.bottomRightItemText}>查看物流</Text>

                        </LinearGradient>
                    </TouchableOpacity>
                )
            }
        } else if (this.state.orderStatus == AfterSaleStatus.OrderStatusFinisded) {

        }

    }

    /**
     * 申请检测
     */
    applyDetection() {

        if (this.Loading) {
            this.Loading.show('申请检测中...')
        }

        let param = {
            orderNo: this.state.orderNo,
        }

        HttpUtils.getRequest(HttpUrls.orderApplyDetection, param)
            .then((result) => {
                if (this.Loading) {
                    this.Loading.hide()
                }
                if (result.code == 0) {
                    setTimeout(() => {

                        navigation.navigate('MessageChat', {
                            imGroupId: result.data.imConversationId ? result.data.imConversationId : '',
                            carId: this.state.orderInfo.carId
                        })
                        this.getOrderDetail()
                    }, 500)

                } else {
                    ToastToUser(result.msg ? result.msg : result.statusText)
                }
            })
            .catch((error) => {
                if (this.Loading) {
                    this.Loading.hide()
                }
            });


    }

    getOrderDetail() {
        let that = this
        let param = {

            afterSalesNo: this.state.orderNo
        }


        HttpUtils.getRequest(HttpUrls.getByAfterSalesByNo, param)
            .then((result) => {
                if (this.Loading) {
                    this.Loading.hide();
                }
                if (result.code == 0 && result.data) {
                    this.setState({
                        orderInfo: result.data,
                        afterSalesType: result.data.afterSalesType,
                        afterSalesStatus: result.data.afterSalesStatus,
                        orderStatus: result.data.afterSalesStatus,
                        isRefund: result.data.isRefund,
                        title: conditionObjWithType('afterSaleOrderStatus')[result.data.afterSalesStatus],
                    })

                    let carAbnormalPics = result.data.carAbnormalPics
                    if (carAbnormalPics) {
                        let pics = carAbnormalPics.split(',')

                        let tempPics = []
                        pics.map((item, index) => {

                            tempPics.push({ url: getImgUrl(item) })
                        })

                        this.setState({
                            showPicList: tempPics
                        })
                    }


                    this.getAfterSalesLastByOrderNo(result.data.quotationOrderNo)

                    if (result.data.logisticsNo) {
                        this.getByLogisticsNo(result.data.logisticsNo)
                    }

                    //applyConfirmTimeOut

                    if (result.data.afterSalesStatus == AfterSaleStatus.OrderStatusWaitConfirm && result.data.applyConfirmTimeOut) {
                        let endDate = result.data.applyConfirmTimeOut

                        const timer = setInterval(() => {
                            endDate = endDate - 1;
                            if (endDate <= 0) {
                                clearInterval(timer);

                            }
                            that.setState({
                                applyConfirmTimeOut: endDate
                            })
                        }, 1000);

                    }

                    //contractSignTimeOut
                    if (result.data.afterSalesStatus == AfterSaleStatus.OrderStatusWaitSign || result.data.afterSalesStatus == AfterSaleStatus.OrderStatusSigning) {
                        if (result.data.contractSignTimeOut) {
                            let endDate = result.data.contractSignTimeOut

                            const timer = setInterval(() => {
                                endDate = endDate - 1;
                                if (endDate <= 0) {
                                    clearInterval(timer);

                                }
                                that.setState({
                                    contractSignTimeOut: endDate
                                })
                            }, 1000);
                        } else {
                            that.setState({
                                contractSignTimeOut: 0
                            })
                        }

                    }

                    if (result.data.afterSalesStatus == AfterSaleStatus.OrderStatusWaitSettlement) {
                        if (result.data.paymentTimeOut) {
                            let endDate = result.data.paymentTimeOut

                            const timer = setInterval(() => {
                                endDate = endDate - 1;
                                if (endDate <= 0) {
                                    clearInterval(timer);

                                }
                                that.setState({
                                    paymentTimeOut: endDate
                                })
                            }, 1000);
                        } else {
                            that.setState({
                                paymentTimeOut: 0
                            })
                        }

                    }

                    //shipmentTimeOut
                    if (result.data.afterSalesStatus == AfterSaleStatus.OrderStatusWaitDelivery) {
                        if (result.data.shipmentTimeOut) {
                            let endDate = result.data.shipmentTimeOut

                            const timer = setInterval(() => {
                                endDate = endDate - 1;
                                if (endDate <= 0) {
                                    clearInterval(timer);

                                }
                                that.setState({
                                    shipmentTimeOut: endDate
                                })
                            }, 1000);
                        } else {
                            that.setState({
                                shipmentTimeOut: 0
                            })
                        }

                    }

                    //receiptTimeOut
                    if (result.data.afterSalesStatus == AfterSaleStatus.OrderStatusWaitReceipt) {
                        if (result.data.receiptTimeOut) {
                            let endDate = result.data.receiptTimeOut

                            const timer = setInterval(() => {
                                endDate = endDate - 1;
                                if (endDate <= 0) {
                                    clearInterval(timer);

                                }
                                that.setState({
                                    receiptTimeOut: endDate
                                })
                            }, 1000);
                        } else {
                            that.setState({
                                receiptTimeOut: 0
                            })
                        }

                        if (result.data.logisticsTimeOut) {
                            let endDate = result.data.logisticsTimeOut

                            const timer = setInterval(() => {
                                endDate = endDate - 1;
                                if (endDate <= 0) {
                                    clearInterval(timer);

                                }
                                that.setState({
                                    logisticsTimeOut: endDate
                                })
                            }, 1000);
                        } else {
                            that.setState({
                                logisticsTimeOut: 0
                            })
                        }

                    }

                }

            })
            .catch((error) => {
                if (this.Loading) {
                    this.Loading.hide();
                }
            });
    }

    getAfterSalesLastByOrderNo(orderNo) {
        HttpUtils.getRequest(HttpUrls.getAfterSalesLastByOrderNo, { quotationOrderNo: orderNo })
            .then((result) => {
                if (result.code == 0) {
                    /**
                     * 获取一下最近一次的申请记录，如果有且申请状态是被卖家拒绝，就显示出来，平台介入按钮
                     */
                    if (result.data && result.data.lastRefuse == '1') {
                        this.setState({
                            isShowPlatformIntervene: true
                        })
                    }
                } else {

                }
            })
            .catch((error) => {

            });
    }


    cancelOrder() {
        let param = {
            afterSalesNo: this.state.orderNo,
        }

        HttpUtils.postRequest(HttpUrls.revokeAfterSales, param)
            .then((result) => {
                if (result.code == 0) {
                    ToastToUser('撤销售后成功')
                    this.getOrderDetail()
                }else{
                    ToastToUser(result.msg ? result.msg : result.statusText)
                }
            })
            .catch((error) => {

            })

    }

    consultOnline() {
        let param = {
            carId: this.state.orderInfo.carId,
            buyerMerchantId: this.state.orderInfo.buyerMerchantId,
            sellerMerchantId: this.state.orderInfo.sellerMerchantId,
            buyerUserId: this.state.orderInfo.buyerUserId,

        }
        if (this.Loading) {
            this.Loading.show();
        }

        HttpUtils.postRequest(HttpUrls.quotationConsult, param)
            .then((result) => {
                if (this.Loading) {
                    this.Loading.hide();
                }
                if (result.code == 0) {

                    setTimeout(() => {
                        navigation.navigate('MessageChat', {
                            imGroupId: result.data.imGroupId,
                            carId: this.state.orderInfo.carId
                        })
                    }, 500);

                } else {
                    ToastToUser(result.msg + '')
                }
                l
            })
            .catch((error) => {
                if (this.Loading) {
                    this.Loading.hide();
                }
            });
    }

    showTypePicker() {
        let pickerData = [
            '方案不认同',
            '金额不认同',
            '检测车况一致',
        ];
        Picker.init({
            pickerData: pickerData,
            selectedValue: [],
            // pickerBg:[255, 0 ,0, 1],
            pickerFontColor: [0, 0, 0, 1],
            pickerCancelBtnText: '取消',
            pickerCancelBtnColor: [134, 136, 137, 1],
            pickerConfirmBtnText: '确认',
            pickerTitleText: '选择原因',
            pickerToolBarBg: [255, 255, 255, 1],
            pickerBg: [255, 255, 255, 1],

            pickerTextEllipsisLen: 10,

            onPickerConfirm: data => {
                const index = pickerData.indexOf(data[0]) + 1;
                this.rejectAfterSaleOrder(index)

            },
            onPickerCancel: data => {

            },
            onPickerSelect: data => {

            }
        });
        Picker.show();
    }


    /**
     * 拒绝售后
     */
    rejectAfterSaleOrder(refuseReason) {
        let params = {
            afterSalesNo: this.state.orderNo,
            refuseReason: refuseReason
        }


        HttpUtils.postRequest(HttpUrls.refuseAfterSales, params)
            .then((result) => {
                if (result.code == 0) {
                    ToastToUser('拒绝售后申请成功')
                    this.getOrderDetail()
                }else{
                    ToastToUser(result.msg ? result.msg : result.statusText)
                }
            })
            .catch((error) => {

            })
    }

    /**
     * 同意售后
     */
    confirmAfterSaleOrder() {
        let params = {
            afterSalesNo: this.state.orderNo,

        }

        HttpUtils.postRequest(HttpUrls.agreeAfterSales, params)
            .then((result) => {
                if (result.code == 0) {
                    ToastToUser('同意售后申请成功')
                    this.getOrderDetail()
                }else{
                    ToastToUser(result.msg ? result.msg : result.statusText)
                }
            })
            .catch((error) => {

            })
    }

    /**
    * 售后确认收货
    */
    afterSaleConfirmReceipt() {
        let params = {
            afterSalesNo: this.state.orderNo,

        }

        HttpUtils.postRequest(HttpUrls.afterSaleConfirmReceipt, params)
            .then((result) => {
                if (result.code == 0) {
                    ToastToUser('确认收货成功')
                    this.setState({
                        confirmReceiptVisible: false
                    })
                    this.getOrderDetail()
                }else{
                    ToastToUser(result.msg ? result.msg : result.statusText)
                }
            })
            .catch((error) => {

            })
    }

    /**
     * 卖家支付退款
     * @param {*} totalAmount 
     */
    confirmPay(totalAmount) {
        let param = {
            userId: Constant.userInfo.userId,
            merchantId: Constant.userInfo.merchantId,
            totalAmount: totalAmount,
            payChannel: 10,
            tradeType: 21,
            operator: Constant.userInfo.fullname,
            outTradeNo: this.state.orderNo
        }

        if (this.Loading) {
            this.Loading.show()
        }
        HttpUtils.postRequest(HttpUrls.paymentOrderGenerate, param)
            .then((result) => {
                if (this.Loading) {
                    this.Loading.hide();
                }
                let code = result.code
                if (code == 0) {
                    let data = result.data
                    let channelResult = data.channelResult
                    if (channelResult) {

                        this.props.navigation.navigate('WebView', { source: channelResult })
                    }
                } else {
                    ToastToUser(result.msg + '')
                }
            })
            .catch((error) => {
                if (this.Loading) {
                    this.Loading.hide();
                }
            });
    }

    /**
     * 获取物流详情
     */
    getByLogisticsNo(logisticsNo) {
        HttpUtils.getRequest(HttpUrls.getByLogisticsNo, { logisticsNo: logisticsNo })
            .then((result) => {
                if (result.code == 0) {
                    let data = result.data;
                    this.setState({
                        logisticsInfo: data
                    })
                } else {
                    ToastToUser(result.msg ? result.msg : result.statusText)
                }
            })
            .catch((error) => {
                // ToastToUser(error)
            });
    }

    /**
     * 平台介入
     */
    applyPlatformProcessing() {
        this.Loading.show()

        HttpUtils.getRequest(HttpUrls.applyPlatformProcessing, { afterSalesNo: this.state.orderNo })
            .then((result) => {
                if (this.Loading) {
                    this.Loading.hide()
                }
                if (result.code == 0) {
                    ToastToUser('平台介入成功')

                } else {
                    ToastToUser(result.msg ? result.msg : result.statusText)
                }
            })
            .catch((error) => {
                // ToastToUser(error)
            });
    }

}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: '#F9F9F9',
    },
    scrollContain: {
        flex: 1
    },
    orderStatusContain: {
        marginTop: 15,
        marginLeft: 15,
        marginRight: 15,
        paddingLeft: 9,
    },
    orderStatusText: {
        fontSize: 18,
        fontWeight: 'bold',
        color: '#000000'
    },
    orderStatusText2: {
        fontSize: 12,
        color: '#666666',
        marginTop: 4
    },
    timeColorText: {
        fontSize: 12,
        color: '#ED542E'
    },
    addressInfoBox: {
        flexDirection: 'row',
        alignItems: 'center',
        marginLeft: 8,
        marginRight: 8,
        padding: 16,
        backgroundColor: '#fff',
        borderRadius: 6,
        marginTop: 10
    },
    locationImg: {
        width: 24,
        height: 24
    },
    addressText: {
        lineHeight: 21,
        fontSize: 15,
        fontWeight: '500',
        color: '#222'
    },
    nameText: {
        marginTop: 6,
        fontSize: 14,
        color: '#666666'
    },
    arrowImg: {
        width: 15,
        height: 15,
        marginLeft: 12,
    },
    orderInfoContain: {
        marginTop: 10,
        marginLeft: 8,
        marginRight: 8,

        backgroundColor: '#fff',
        borderRadius: 6,
        paddingHorizontal: 16,
        paddingVertical: 12,
    },
    carImg: {
        width: 130,
        height: 90,
        borderRadius: 4,
        backgroundColor: '#f5f5f5'
    },
    carInfoBox: {
        flex: 1,
        flexDirection: 'column',

        // justifyContent: 'space-between',
        marginLeft: 12,
        height: 90,

    },
    brandText: {
        // lineHeight: 20,
        color: '#333333',
        fontSize: 14,
        fontWeight: '500'
    },
    carInfoText: {
        marginTop: 8,
        fontSize: 12,
        color: '#333',
    },
    carPriceText: {
        marginTop: 8,
        fontSize: 14,
        color: '#333333'
    },

    itemPriceContain: {
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'space-between',
        height: 46
    },
    itemPriceTitle: {
        fontSize: 14,
        color: '#333333'
    },
    itemPriceValue: {
        fontSize: 14,
        color: '#333333',
        fontWeight: 'bold'
    },
    titleText: {
        fontSize: 16,
        color: '#333333',
        fontWeight: 'bold',
        marginBottom: 10
    },
    infoBox: {
        height: 46,
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'space-between',
    },
    infoBoxNoHeight: {
        minHeight: 46,
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'space-between',
    },
    infoBox2: {
        height: 46,
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'space-between',
        paddingLeft: 16,
        paddingRight: 16
    },
    moneyInfoBox: {
        backgroundColor: '#f6f6f6',
    },
    itemTitleText: {
        color: '#333',
        fontSize: 14,
    },
    itemPriceText: {
        fontSize: 14,
        fontWeight: '500',
        color: '#333'
    },
    lookBankInfoContain: {
        height: 50,
        justifyContent: 'center',
        alignItems: 'center'
    },
    lookBtnText: {
        fontSize: 14,
        color: '#FF7B00'
    },

    arrowRightImage: {
        width: 15,
        height: 15
    },

    bottomContain: {
        // height: 60,
        backgroundColor: '#fff',
        borderTopColor: '#e4e4e4',
        borderTopWidth: 0.3,
        paddingTop: 5
    },
    bottomContain2: {
        height: 50,
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'space-between',
        paddingHorizontal: 16

    },
    bottomitemBox: {
        height: '100%',
        width: 45,
        marginRight: 5,
        flexDirection: 'column',
        justifyContent: 'center',
        alignItems: 'center',
    },
    bottomitemImg: {
        width: 18,
        height: 18
    },
    bottomitemText: {
        color: '#333333',
        fontSize: 10,
        marginTop: 4,
    },
    bottomBtn1: {
        width: 120,
        height: 36,
        justifyContent: 'center',
        alignItems: 'center',

        borderRadius: 36
    },
    bottomBtnCancel: {
        width: 140,
        height: 36,
        justifyContent: 'center',
        alignItems: 'center',

        borderRadius: 36,
        borderColor: '#E5E5E5',
        borderWidth: 1,
        marginRight: 12
    },
    itemInnerBox: {
        width: '100%',
        height: '100%',
        justifyContent: 'center',
        alignItems: 'center',
        borderRadius: 18,

    },
    bottomRightItemText: {
        color: '#333333',
        fontSize: 14
    },
    contractFeeContain: {
        height: 42,
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'space-between',
        paddingHorizontal: 16
    },

    carbottomContain: {
        height: 48,
        flexDirection: 'row',
        alignItems: 'center',
        justifyContent: 'flex-end',

    },
    carBottomBtn: {
        width: 88,
        height: 32,
        justifyContent: 'center',
        alignItems: 'center',
        borderRadius: 36,
        borderColor: '#E5E5E5',
        borderWidth: 1,
        marginLeft: 10
    },
    carBottomBtnText: {
        color: '#333333',
        fontSize: 14
    },
    copyImg: {
        width: 20,
        height: 20
    },

})